package com.hibernate.hrm.entity.dto.position;

import com.hibernate.hrm.entity.Department;
import com.hibernate.hrm.entity.Position;
import com.hibernate.hrm.entity.Role;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
public class PositionDetailDTO {
    private Integer positionId;
    private Department department;
    private String positionName;
    private String positionCode;
    private Role positionRole;
    private Integer maxHeadCount;
    private BigDecimal baseSalary;
    private BigDecimal allowance;
    private BigDecimal annualLeaveDays;
    private Boolean status;
    private LocalDateTime createTime;
    private LocalDateTime updateTime;

    public static PositionDetailDTO fromEntity(Position position) {
        PositionDetailDTO dto = new PositionDetailDTO();
        dto.setPositionId(position.getPositionId());
        dto.setDepartment(position.getDepartmentID());
        dto.setPositionName(position.getPositionName());
        dto.setPositionCode(position.getPositionCode());
        dto.setPositionRole(position.getPositionRoleID());
        dto.setMaxHeadCount(position.getMaxHeadCount());
        dto.setBaseSalary(position.getBaseSalary());
        dto.setAllowance(position.getAllowance());
        dto.setAnnualLeaveDays(position.getAnnualLeaveDays());
        dto.setStatus(position.getStatus());
        dto.setCreateTime(position.getCreateTime());
        dto.setUpdateTime(position.getUpdateTime());
        return dto;
    }
}